<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2603：[Poi2003]Motorways</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Poi2003]Motorways</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Poi2003]Motorways</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Poi2003]Motorways                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p><span style="font-size: medium"><span lang="EN-US"><font face="Verdana">Byteotia </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">城位于一个半岛上</span><span lang="EN-US"><font face="Verdana">. </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">从</span><span lang="EN-US"><font face="Verdana">king Bitol </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">开始铁路开始成为</span><span lang="EN-US"><font face="Verdana">Byteotia</font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">主要的交通途径</span><span lang="EN-US"><font face="Verdana">. King Bitol </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">建造了一个超速铁路线</span><span lang="EN-US"><font face="Verdana">. </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这条干线连接了半岛的西边和东边</span><span lang="EN-US"><font face="Verdana">, </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">经过了</span><span lang="EN-US"><font face="Verdana">Byteotia </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的所有城镇</span><span lang="EN-US"><font face="Verdana">,</font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">这些城镇从</span><span lang="EN-US"><font face="Verdana">1 </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">到</span><font face="Verdana"> <i><span lang="EN-US">n</span></i><span lang="EN-US">. </span></font><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">城镇</span><span lang="EN-US"><font face="Verdana">1 </font></span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在西海岸而城镇</span><font face="Verdana"><i><span lang="EN-US">n</span></i><span lang="EN-US"> </span></font><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在东海岸</span><span lang="EN-US"><font face="Verdana">.</font></span></span></p>
<p><span style="font-size: medium"><span lang="EN-US"><font face="Verdana"><img height="290" width="255" alt="" src="../file/2603_0.jpg" /></font></span></span></p>
<p><span lang="EN-US"><font face="Verdana">
<p><span style="font-size: medium"><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">最近多亏了总理</span><span lang="EN-US">Byterowicz, Byteotia </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的经济增长十分迅速而且交通系统变得非常的现代化</span><span lang="EN-US">. King Byteol </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">下命令建造一些摩托车道</span><span lang="EN-US">. </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">每个摩托车道直接连接两个选定的地点</span><span lang="EN-US">. </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">因为每条摩托车道都是由不同的政府部门负责修建</span><span lang="EN-US">, </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">所以任何一条摩托车道都不能和其他的相交</span><span lang="EN-US">. </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">每条摩托车道要么修建在铁路的北面或者南面</span><span lang="EN-US">. Figure 2 </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">展示了一个简单的摩托车道修建计划</span><span lang="EN-US">(</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">摩托车道为虚线</span><span lang="EN-US">, </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">铁路为实线</span><span lang="EN-US">).</span></span></p>
<p><span style="font-size: medium"><span lang="EN-US"><img height="305" width="266" alt="" src="../file/2603_1.jpg" /></span></span></p>
<p></p>
<span style="font-size: medium"><span lang="EN-US">
<p><span lang="EN-US">King Byteol </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">已经决定了哪些城镇将被摩托车道相连</span><span lang="EN-US">. </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">你的任务就是决定每条摩托车道是修建在铁路的南面还是北面</span><span lang="EN-US">. </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">记住</span><span lang="EN-US">,</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">任何情况下摩托车道都不能互相交叉</span><span lang="EN-US">. </span></p>
</span></span><span lang="EN-US">
<p></p>
</span></font></span></p></p><hr/><h3>输入格式</h3><p><div><span style="font-size: medium">第一行两个整数: 城镇数<i>n</i>和要建造的摩托车道数<i>k</i>, 1 &lt;= <i>n</i>,<i>k</i> &lt;= 20000. 接下来k行每行两个数<i>p<sub>i</sub></i>, <i>q<sub>i</sub></i>: 表示第<i>i</i>条摩托车道要连接的两个城镇, 1 &lt;= <i>p<sub>i</sub></i> &lt; <i>q<sub>i</sub></i> &lt;= <i>n</i>. 一对城镇最多出现一次. </span></div>
<p></p></p><hr/><h3>输出格式</h3><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-size: medium"><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果不存在合法的建造方案</span><span lang="EN-US" style="font-family: Verdana">,</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">输出</span><tt><span lang="EN-US"><font face="宋体">NIE</font></span></tt><span lang="EN-US" style="font-family: Verdana">, </span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">否则输出一组方案</span><span lang="EN-US" style="font-family: Verdana">,</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">每行一个字母</span><span lang="EN-US" style="font-family: Verdana">N</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">或者</span><span lang="EN-US" style="font-family: Verdana">S</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">表示第</span><span lang="EN-US" style="font-family: Verdana">i</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">条摩托车道是修建在北边</span><span lang="EN-US" style="font-family: Verdana">(N)</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">还是南边</span><span lang="EN-US" style="font-family: Verdana">(S).</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果有多种方案</span><span lang="EN-US" style="font-family: Verdana">,</span><span style="font-family: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">输出任意一种即可</span><span lang="EN-US" style="font-family: Verdana">. </span></span><span lang="EN-US" style="font-size: 9pt; font-family: Verdana"><o:p></o:p></span></p></p><hr/><h3>样例输入</h3><pre>8 7
1 2
1 3
2 4
5 7
4 8
7 8
6 8
</pre><hr/><h3>样例输出</h3><pre>N
N
S
S
S
N
N
</pre><hr/><h3>提示</h3><p><p>请不要提交，希望有人提供SPJ.</p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2603" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2603" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>